package cdu.sl.controller;


import cdu.sl.pojo.Emp;
import cdu.sl.pojo.LoginInfo;
import cdu.sl.pojo.Result;
import cdu.sl.service.EmpService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController()
@RequestMapping("/login")
public class LoginController {
    private static final Logger log = LoggerFactory.getLogger(LinkageError.class);

    @Autowired
    private EmpService empService;

    /**
     * 登录
     */
    @PostMapping
    public Result login(@RequestBody Emp emp) {
        log.info("登录：{}", emp);
        LoginInfo loginInfo = empService.login(emp);
        if (loginInfo != null) {
            return Result.success(loginInfo);
        } else
            return Result.error("用户名或密码错误");
    }





}
